using System;
using System.Collections.Generic;
using System.Text;
using iTunesLib;
using System.IO;

namespace Teknologika.iPodConverter
{
    public class iTunes
    {

        public void AddFile(string fileName)
        {
            if (fileName == null)
            {
                throw new ApplicationException("A filename was not passed to AddFile, unable to continue");
            }


            FileInfo file = new FileInfo(fileName);
            if (!file.Exists)
            {
                throw new ApplicationException("An error occurred, unable to add the file '" + fileName + "' does not exist");
            }

            else
            {
                try
                {
                    iTunesApp itunes = new iTunesAppClass();
                    itunes.LibraryPlaylist.AddFile(fileName);

                }
                catch (Exception e)
                {
                    throw new ApplicationException("An error occurred, unable to add the file '" + fileName + "'.\nThe error was:\n\n" + e.Message);
                }
            }
            

        }

    }

     

}
